home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 67 / IOPROG_67A.ISO / soft / Tools / mwsppv4.exe / SOURCE CONTROL.SCRIPT < prev    next >
Encoding:
Text File  |  2002-09-03  |  12.3 KB  |  216 lines

  1. !!Script
  2. // Copyright ⌐ 1997-2001 - Modelworks Software
  3.  
  4. /**
  5. @Tool: Source Control~defines the Source Control toolbar. This
  6. toolbar uses the sourceControl property set in the project to 
  7. determine which source control database is used.
  8. @EndTool: 
  9. @Summary: Source Control~defines the Source Control toolbar
  10. */
  11.  
  12. var gOutput = getOutput();
  13.  
  14. function OnNotify(event, cookie)
  15. {
  16.     var toolbar = getGlobal("SourceControlToolbar");
  17.     if (event == "project.changed")
  18.     {
  19.         if (toolbar)
  20.         {
  21.             var activate = false;
  22.             var configure = false;
  23.             var project = getCurrentProject();
  24.             if (project)
  25.             {
  26.                 activate = project.sourceControl.length > 0;
  27.                 
  28.                 if (activate)
  29.                 {
  30.                     var currentPath = getGlobal("SourceControlToolbar.ScriptPath");
  31.                     var newPath = "Source Control\\" + project.sourceControl + "\\";
  32.                     if (currentPath != newPath)
  33.                     {
  34.                         setGlobal("SourceControlToolbar.ScriptPath", newPath);
  35.                         UpdateToolBar(toolbar, newPath);
  36.                     }
  37.                     
  38.                     var configurePath = File.getToolsPath() + "\\" + newPath + "configure.dscript";
  39.                     configure = pathExists(configurePath);                
  40.                     
  41.                 }
  42.             }
  43.             
  44.             toolbar.enableButton(getGlobal("SourceControlToolbar.AddID"), activate);
  45.             toolbar.enableButton(getGlobal("SourceControlToolbar.GetID"), activate);
  46.             toolbar.enableButton(getGlobal("SourceControlToolbar.CheckOutID"), activate);
  47.             toolbar.enableButton(getGlobal("SourceControlToolbar.CheckOutODocID"), activate);
  48.             toolbar.enableButton(getGlobal("SourceControlToolbar.CheckInID"), activate);
  49.             toolbar.enableButton(getGlobal("SourceControlToolbar.CheckInODocID"), activate);
  50.             toolbar.enableButton(getGlobal("SourceControlToolbar.CheckInKeepCheckOutID"), activate);
  51.             toolbar.enableButton(getGlobal("SourceControlToolbar.CheckInKeepCheckOutODocID"), activate);
  52.             toolbar.enableButton(getGlobal("SourceControlToolbar.UndoCheckOutID"), activate);
  53.             toolbar.enableButton(getGlobal("SourceControlToolbar.StatusID"), activate);
  54.             toolbar.enableButton(getGlobal("SourceControlToolbar.ConfigureID"), configure);
  55.         }
  56.     }
  57.     else if (cookie == toolbar && event == "toolbar.show")
  58.     {
  59.         var project = getCurrentProject();
  60.         if (project && project.sourceControl.length == 0)
  61.         {
  62.             alert("To activate the source control toolbar choose a\nsource control database using the Project menu's Add Package\nor Edit Package commands");
  63.         }
  64.         else if (project == null)
  65.         {
  66.             alert("To activate the source control toolbar create or\nopen a project and choose a source control database\nusing the Add Package or Edit Package commands");
  67.         }
  68.     }
  69. }
  70.  
  71. function DoCommand() 
  72. {
  73.     var toolbar = newToolBar("Source Control", "docked");
  74.     setGlobal("SourceControlToolbar", toolbar);
  75.     Application.registerNotify(getScriptPath(), "project.changed"); // call OnNotify when a project is changed
  76.     Application.registerNotify(getScriptPath(), "toolbar.show"); // call OnNotify when toolbar.show is called
  77.  
  78.     var ssPath = "Source Control\\Vss\\"; // initial source control
  79.     setGlobal("SourceControlToolbar.ScriptPath", ssPath);
  80.  
  81.     var buttonAdd = newToolBarButton("icon");
  82.     buttonAdd.scriptPath = ssPath + "add.script";
  83.     buttonAdd.imagePath = "Toolbars\\Images\\Source Control\\add.bmp"; 
  84.     buttonAdd.description = "Add a file to the source control system";
  85.     buttonAdd.toolTipText = "Add";
  86.     var AddID = toolbar.setButton(0, buttonAdd);
  87.     
  88.     var buttonGet = newToolBarButton("icon");
  89.     buttonGet.scriptPath = ssPath + "get.script";
  90.     buttonGet.imagePath = "Toolbars\\Images\\Source Control\\get.bmp"; 
  91.     buttonGet.description = "Get a file from the source control system";
  92.     buttonGet.toolTipText = "Get";
  93.     var GetID = toolbar.setButton(1, buttonGet);
  94.  
  95.     var buttonCheckIn = newToolBarButton("icon");
  96.     buttonCheckIn.scriptPath = ssPath + "checkIn.script";
  97.     buttonCheckIn.imagePath = "Toolbars\\Images\\Source Control\\checkin.bmp"; 
  98.     buttonCheckIn.description = "Check In a file to the source control system";
  99.     buttonCheckIn.toolTipText = "Check in";
  100.     var CheckInID = toolbar.setButton(2, buttonCheckIn);
  101.     
  102.     var buttonCheckOut = newToolBarButton("icon");
  103.     buttonCheckOut.scriptPath = ssPath + "checkOut.script";
  104.     buttonCheckOut.imagePath = "Toolbars\\Images\\Source Control\\checkout.bmp"; 
  105.     buttonCheckOut.description = "Check Out a file from the source control system";
  106.     buttonCheckOut.toolTipText = "Check Out";
  107.     var CheckOutID = toolbar.setButton(3, buttonCheckOut);
  108.  
  109.     var buttonCheckInKeepCheckOut = newToolBarButton("icon");
  110.     buttonCheckInKeepCheckOut.scriptPath = ssPath + "checkInKeepCheckOut.script";
  111.     buttonCheckInKeepCheckOut.imagePath = "Toolbars\\Images\\Source Control\\checkinkeepcheckout.bmp"; 
  112.     buttonCheckInKeepCheckOut.description = "Check In, keep Check Out from the source control system";
  113.     buttonCheckInKeepCheckOut.toolTipText = "Check In, keep Check Out";
  114.     var CheckInKeepCheckOutID = toolbar.setButton(4, buttonCheckInKeepCheckOut);
  115.  
  116.     var buttonCheckInODoc = newToolBarButton("icon");
  117.     buttonCheckInODoc.scriptPath = ssPath + "checkInOpenDocuments.script";
  118.     buttonCheckInODoc.imagePath = "Toolbars\\Images\\Source Control\\checkinod.bmp"; 
  119.     buttonCheckInODoc.description = "Check In open documents to the source control system";
  120.     buttonCheckInODoc.toolTipText = "Check In open documents";
  121.     var CheckInODocID = toolbar.setButton(5, buttonCheckInODoc);
  122.     
  123.     var buttonCheckOutODoc = newToolBarButton("icon");
  124.     buttonCheckOutODoc.scriptPath = ssPath + "checkOutOpenDocuments.script";
  125.     buttonCheckOutODoc.imagePath = "Toolbars\\Images\\Source Control\\checkoutod.bmp"; 
  126.     buttonCheckOutODoc.description = "Check Out open documents from the source control system";
  127.     buttonCheckOutODoc.toolTipText = "Check Out open documents";
  128.     var CheckOutODocID = toolbar.setButton(6, buttonCheckOutODoc);
  129.  
  130.     var buttonCheckInKeepCheckOutODoc = newToolBarButton("icon");
  131.     buttonCheckInKeepCheckOutODoc.scriptPath = ssPath + "checkInKeepCheckOutOpenDocuments.script";
  132.     buttonCheckInKeepCheckOutODoc.imagePath = "Toolbars\\Images\\Source Control\\checkinkeepcheckoutod.bmp"; 
  133.     buttonCheckInKeepCheckOutODoc.description = "Check In, keep Check Out open documents from the source control system";
  134.     buttonCheckInKeepCheckOutODoc.toolTipText = "Check In, keep Check Out open documents";
  135.     var CheckInKeepCheckOutODocID = toolbar.setButton(7, buttonCheckInKeepCheckOutODoc);
  136.  
  137.     var buttonUndoCheckOut = newToolBarButton("icon");
  138.     buttonUndoCheckOut.scriptPath = ssPath + "undoCheckOut.script";
  139.     buttonUndoCheckOut.imagePath = "Toolbars\\Images\\Source Control\\undocheckout.bmp"; 
  140.     buttonUndoCheckOut.description = "Undo Check Out from the source control system";
  141.     buttonUndoCheckOut.toolTipText = "Undo Check Out";
  142.     var UndoCheckOutID = toolbar.setButton(8, buttonUndoCheckOut);
  143.  
  144.     var buttonStatus = newToolBarButton("icon");
  145.     buttonStatus.scriptPath = ssPath + "status.script";
  146.     buttonStatus.imagePath = "Toolbars\\Images\\Source Control\\status.bmp"; 
  147.     buttonStatus.description = "Get the status of the source control system";
  148.     buttonStatus.toolTipText = "Status";
  149.     var StatusID = toolbar.setButton(9, buttonStatus);
  150.  
  151.     var buttonConfigure = newToolBarButton("icon");
  152.     buttonConfigure.scriptPath = ssPath + "configure.dscript";
  153.     buttonConfigure.imagePath = "Toolbars\\Images\\Source Control\\configure.bmp"; 
  154.     buttonConfigure.description = "Edit parameters and options needed for the source control system";
  155.     buttonConfigure.toolTipText = "Configure";
  156.     var ConfigureID = toolbar.setButton(10, buttonConfigure);
  157.  
  158.     setGlobal("SourceControlToolbar.AddID", AddID);
  159.     setGlobal("SourceControlToolbar.GetID", GetID);
  160.     setGlobal("SourceControlToolbar.CheckInID", CheckInID);
  161.     setGlobal("SourceControlToolbar.CheckOutID", CheckOutID);
  162.     setGlobal("SourceControlToolbar.CheckInKeepCheckOutID", CheckInKeepCheckOutID);
  163.     setGlobal("SourceControlToolbar.CheckInODocID", CheckInODocID);
  164.     setGlobal("SourceControlToolbar.CheckOutODocID", CheckOutODocID);
  165.     setGlobal("SourceControlToolbar.CheckInKeepCheckOutODocID", CheckInKeepCheckOutODocID);
  166.     setGlobal("SourceControlToolbar.UndoCheckOutID",UndoCheckOutID);
  167.     setGlobal("SourceControlToolbar.StatusID", StatusID);
  168.     setGlobal("SourceControlToolbar.ConfigureID", ConfigureID);
  169.     
  170.     toolbar.enableButton(getGlobal("SourceControlToolbar.AddID"), false);
  171.     toolbar.enableButton(getGlobal("SourceControlToolbar.GetID"), false);
  172.     toolbar.enableButton(getGlobal("SourceControlToolbar.CheckInID"), false);
  173.     toolbar.enableButton(getGlobal("SourceControlToolbar.CheckOutID"), false);
  174.     toolbar.enableButton(getGlobal("SourceControlToolbar.CheckInKeepCheckOutID"), false);
  175.     toolbar.enableButton(getGlobal("SourceControlToolbar.CheckInODocID"), false);
  176.     toolbar.enableButton(getGlobal("SourceControlToolbar.CheckOutODocID"), false);
  177.     toolbar.enableButton(getGlobal("SourceControlToolbar.CheckInKeepCheckOutODocID"), false);
  178.     toolbar.enableButton(getGlobal("SourceControlToolbar.UndoCheckOutID"), false);
  179.     toolbar.enableButton(getGlobal("SourceControlToolbar.StatusID"), false);
  180.     toolbar.enableButton(getGlobal("SourceControlToolbar.ConfigureID"), false);
  181.     
  182.     
  183.     toolbar.restoreState();
  184. }
  185.     
  186. function UpdateToolBar(toolbar, ssPath)
  187. {        
  188.     var AddID                     = toolbar.setButton( 0,  ssPath + "add.script", "Add a file to the source control system", "Add");
  189.     var GetID                     = toolbar.setButton( 1,  ssPath + "get.script", "Get a file from the source control system", "Get");
  190.     var CheckInID                 = toolbar.setButton( 2,  ssPath + "checkIn.script", "Check in a file to the source control system", "Check In");
  191.     var CheckOutID                = toolbar.setButton( 3,  ssPath + "checkOut.script", "Check Out a file from the source control system", "Check Out");
  192.     var CheckInKeepCheckOutID     = toolbar.setButton( 4,  ssPath + "checkInKeepCheckOut.script", "Check In, Keep Check Out a file from the source control system", "Check In, Keep CheckOut");
  193.     var CheckInODocID             = toolbar.setButton( 5,  ssPath + "checkInOpenDocuments.script", "Check in open documents to the source control system", "Check In open documents");
  194.     var CheckOutODocID            = toolbar.setButton( 6,  ssPath + "checkOutOpenDocuments.script", "Check Out open documents from the source control system", "Check Out open documents");
  195.     var CheckInKeepCheckOutODocID = toolbar.setButton( 7,  ssPath + "checkInKeepCheckOutOpenDocuments.script", "Check In, Keep Check Out open documents from the source control system", "Check In, Keep CheckOut open documents");
  196.     var UndoCheckOutID            = toolbar.setButton( 8,  ssPath + "undoCheckOut.script", "Undo Check Out from the source control system", "Undo Check Out");
  197.     var StatusID                  = toolbar.setButton( 9,  ssPath + "status.script", "Get the status of the source control system", "Status");
  198.     var ConfigureID               = toolbar.setButton( 10, ssPath + "configure.dscript", "Edit parameters and options needed for the source control system", "Configure");
  199.  
  200.     setGlobal("SourceControlToolbar.AddID", AddID);
  201.     setGlobal("SourceControlToolbar.GetID", GetID);
  202.     setGlobal("SourceControlToolbar.CheckInID", CheckInID);
  203.     setGlobal("SourceControlToolbar.CheckOutID", CheckOutID);
  204.     setGlobal("SourceControlToolbar.CheckInKeepCheckOutID", CheckInKeepCheckOutID);
  205.     setGlobal("SourceControlToolbar.CheckInODocID", CheckInODocID);
  206.     setGlobal("SourceControlToolbar.CheckOutODocID", CheckOutODocID);
  207.     setGlobal("SourceControlToolbar.CheckInKeepCheckOutODocID", CheckInKeepCheckOutODocID);
  208.     setGlobal("SourceControlToolbar.UndoCheckOutID",UndoCheckOutID);
  209.     setGlobal("SourceControlToolbar.StatusID", StatusID);
  210.     setGlobal("SourceControlToolbar.ConfigureID", ConfigureID);
  211. }
  212.  
  213.  
  214. !!/Script
  215.  
  216.